/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { AreaHTMLAttributes, CSSProperties, VNode } from 'vue';
type AttrsMap<T, R = string> = {
  [key in keyof T]: R;
};

export interface IPropsType {
  tag: string;
  text?: string;
  style?: AttrsMap<CSSProperties>;
  attr?: AttrsMap<AreaHTMLAttributes>;
}

interface ComponentData {
  id: string;
  name: string;
  children?: ComponentData[];
  props: IPropsType;
  eventName?: keyof HTMLElementEventMap;
  events?: {
    [key in keyof HTMLElementEventMap]: (e: Event) => void;
  };
}

type OmitComponentDataType<T extends keyof ComponentData> = Omit<ComponentData, T>;

export type ComponentDataType = OmitComponentDataType<'eventName'>;
export type LeftLabelComponentType = OmitComponentDataType<'eventName' | 'events'>;

export interface TextCompnoentProps {
  text?: string;
  color: string;
  fontSize: string;
  lineHeight: string;
  fontFamily: string;
  textAlign: string;
}

type ComponentInfoValueType = string | number | boolean | Event;

export interface IComponentInfo {
  component: unknown;
  subComponent?: unknown;
  subComponentProps?: { [key: string]: any };
  label?: string;
  valueAlias?: string;
  extraProps?: {
    options?: Array<{ label: string | VNode; value: string }>;
    [key: string]: unknown;
  };
  componentStyle?: AttrsMap<CSSProperties, string | number>;
  before?(params: string): Omit<ComponentInfoValueType, 'Event'>;
  after?(params: ComponentInfoValueType): ComponentInfoValueType;
  eventName?: string;
}

export type ComponentInfoType = {
  [prop in keyof TextCompnoentProps]?: IComponentInfo;
};

export interface CompnoentUpadateInfo {
  key: string;
  value: ComponentInfoValueType;
}
